<?php
//  PULSAR, THE GAME
//  ================================
//  COPYRIGHT(c) 2013 BY KAMIL MRZYGŁÓD
//  CODENOVA.PL

namespace Modules\Core {
    final class Core {

        const MODELS_DIR = '../../Models';
        const MODULES_DIR = '..';

        public static function LoadModel($model) {
            if(file_exists(self::MODELS_DIR . DIRECTORY_SEPARATOR . $model . '.php')) {
                /** @noinspection PhpIncludeInspection */
                require_once self::MODELS_DIR . DIRECTORY_SEPARATOR . $model . '.php';
            }
            else
            {
                die('Error');
            }
        }

        /**
         * Load Propel
         */
        public static function LoadPropel() {
            // Include the main Propel script
            require_once '../../Vendor/Propel/runtime/lib/Propel.php';

            // Initialize Propel with the runtime configuration
            \Propel::init("../../../Database/build/conf/pulsar-conf.php");

            // Add the generated 'classes' directory to the include path
            set_include_path("../../../Database/build/classes" . PATH_SEPARATOR . get_include_path());
        }

        public static function FillModel($model, array $data) {
            foreach($data as $el) {
                var_dump(get_object_vars($model));
            }
        }

        /**
         * @param $moduleName
         * @param $fileName
         */
        public static function RequireModule($moduleName, $fileName) {
            if(file_exists(self::MODULES_DIR . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . $fileName . '.php')) {
                /** @noinspection PhpIncludeInspection */
                require_once self::MODULES_DIR . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . $fileName . '.php';
            }
            else
            {
                die('Error');
            }
        }
    }
}

 